<template>
  <div>
    <el-dialog :visible.sync="dialogVisible" width="450px">
      <el-form class="demo-form-inline" label-width="110px">
        <el-form-item label="类型名称">
          <el-input v-model="data.typeName" />
        </el-form-item>

        <el-form-item label="手机端图片路径">
          <el-input v-model="data.imgPath" />
        </el-form-item>

        <!-- <el-form-item label="手机端图片路径">
          <el-upload ref="up1"  
            class="upload-demo"
            action="/myupload/upload/img?type=brand"
            :on-success="logoSuccess"
            :on-remove="logoRemove"
            :file-list="logoFileList"
            list-type="picture"
          >
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
          </el-upload>
        </el-form-item> -->
        <el-form-item label="PC端ICON">
          <el-input v-model="data.icon" />
        </el-form-item>

         <el-form-item label="排序号" v-if="data.id">
          <el-input v-model="data.orderNumber" />
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit()">提 交</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import apigoodsType from "@/api/frontManage/goodsType";
export default {
  name: "dialogTypeEdit",
  data() {
    return {
      dialogVisible: false,
      /*logoFileList: [],*/
      data: {
        typeName: "", //名称
        imgPath: "", //商品类型
        icon: "", //icon
        id:"",
      }
    };
  },
  methods: {
    //修改
    openEdit(row) {
      this.dialogVisible = true;
      apigoodsType.getGoodsTypeById(row.id).then(res => {
        this.data = res.data.goodsTypeInfo;
        // this.logoFileList = [{name:"手机端图片",url:imgPath}]
      });
    },
    //新增
    openadd() {
      this.data = {};
      this.dialogVisible = true; 
    },

    //提交
    submit() {
      apigoodsType.saveOrUpdateGoodsType(this.data).then(res => {
          this.$parent.getList(); //调父组件方法 刷新表格
          this.dialogVisible = false;
        });
    }
  }
};
</script>

<style  scoped>
</style>